import $store from '@/sheep/store';
// id = 权限名
// successCallBack = 成功回调函数
// failCallBack = 失败回调函数
// show = 是否显示常驻弹窗
export function showAuditModal(id, successCallBack, failCallBack,show = false) {
	const permission = $store('permission')
	permission.$patch((state) => {
		state.permissionID = id;
		state.success = successCallBack;
		state.fail = failCallBack;
		// 获取页面栈 将当前页面存入list里面
		// 每次跳转页面在router.js里面判断是否显示常驻弹窗
		if (show) {
			const pages = getCurrentPages()
			const path = pages[pages.length - 1].route
			let res = state.pagesList.findIndex(item => item === path)
			if (res === -1) {
				state.pagesList.push(`/${path}`)
			}
		}
	});
	permission.requestPermissions()
}

// 默认进入首页就打开定位常驻弹窗   点击去开启获取权限  被拒绝了隐藏弹窗 且本次运行中都不会显示
export function showAuditContinue() {
	const permission = $store('permission')
	permission.$patch((state) => {
		if (state.locate === 1) {
			state.bottomShow = false
		} else {
			state.bottomShow = true
		}
	})
}